/*
 * Copyright 2011 evswork Team
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package org.evswork.getwit;

import org.evswork.getwit.regexp.RegExpListAdapter;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;

public class RegExpActivity extends Activity implements OnClickListener {
	ListView RegList;
	Button EnableBtn,DisableBtn,CloseBtn;
	RegExpListAdapter adapter;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.regexp_manage);
		bindView();
	}

	private void bindView() {
		RegList = (ListView)this.findViewById(R.id.lv_regexp);
		adapter = new RegExpListAdapter(this);
		RegList.setAdapter(adapter);
		
		EnableBtn = (Button)this.findViewById(R.id.btn_enable_all);
		DisableBtn = (Button)this.findViewById(R.id.btn_disable_all);
		CloseBtn = (Button)this.findViewById(R.id.btn_return);
		
		EnableBtn.setOnClickListener(this);
		DisableBtn.setOnClickListener(this);
		CloseBtn.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_enable_all:
			adapter.setAllTo(true);
			break;
		case R.id.btn_disable_all:
			adapter.setAllTo(false);
			break;
		case R.id.btn_return:
			finish();
			break;
		}
	}

}
